<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
 <link rel="stylesheet" href="../static/css/back/font.css">
 <link rel="stylesheet" href="../static/css/back/role.css">
    <link rel="stylesheet" href="../static/css/back/xadmin.css">
    <script type="text/javascript" src="../static/js/jquery-2.1.1.min.js"></script>
    <script type="text/javascript" src="../static/js/jquery.md5.js"></script>
    
    <script type="text/javascript" src="../static/js/back/xadmin.js"></script>
   
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  
  <body>
    <div class="x-body">
        <form action="" method="post" class="layui-form" lay-filter="formAdd">
        		<input type="hidden" name="id" value="" id="paramKey" />
                <div class="layui-form-item">
                    <label for="name" class="layui-form-label">
                        <span class="x-red">*</span>账号
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="name" name="userAccount" required="" lay-verify="required|account"
                        autocomplete="off" class="layui-input" placeholder="请输入6位以上账号">
                        <div class="layui-form-mid layui-word-aux">请填写6位字符以上账号</div>
                    </div>
                </div>
			<div class="layui-form-item">
				<label class="layui-form-label"><span class="x-red">*</span>密码</label>
				<div class="layui-input-inline">
					<input type="text"  class="disabled hide">
					<input type="password" name="userPwd" lay-verify="required|pass"
						autocomplete="off" class="layui-input" placeholder="请填写6到12位密码">
				<div class="layui-form-mid layui-word-aux">请填写6到12位密码</div>
				</div>
			</div>
			  
			<div class="layui-form-item">
			      <label class="layui-form-label"><span class="x-red">*</span>权限组</label>
			      <div class="layui-input-inline">
			        <select class="ruleIds" name="ruleId" lay-verify="required" lay-search="">
			          <option value="">无</option>
			        </select>
			      </div>
		   </div>
			 
			<div class="layui-form-item add_bot_btn">
               		 <button class="layui-btn" lay-submit="" lay-filter="add">确定</button>
               		 <button class="layui-btn" onclick="x_admin_close()">取消</button>
              	</div>
            </form>
    </div>
    
     Welcome<br/>  
    <input id="text" type="text"/>  
        <button onclick="send()">发送消息</button>  
        <hr/>       
        <button onclick="closeWebSocket()">关闭WebSocket连接</button>  
        <hr/>  
        <div id="message"></div>  
    <script>
      var websocket = null;  
           //判断当前浏览器是否支持WebSocket  
           if ('WebSocket' in window) {  
              websocket = new WebSocket("ws://"+window.location.hostname+":8888/cityRun/websocket");  
          }  
          else {  
              alert('当前浏览器 Not support websocket')  
          }  
         
          //连接发生错误的回调方法  
          websocket.onerror = function () {  
               setMessageInnerHTML("WebSocket连接发生错误");  
          };  
         
           //连接成功建立的回调方法  
           websocket.onopen = function () {  
               setMessageInnerHTML("WebSocket连接成功");  
           }  
         
          //接收到消息的回调方法  
           websocket.onmessage = function (event) {  
               setMessageInnerHTML(event.data);  
          }  
        
           //连接关闭的回调方法  
           websocket.onclose = function () {  
              setMessageInnerHTML("WebSocket连接关闭");  
           }  
         
           //监听窗口关闭事件，当窗口关闭时，主动去关闭websocket连接，防止连接还没断开就关闭窗口，server端会抛异常。  
           window.onbeforeunload = function () {  
               closeWebSocket();  
           }  
         
           //将消息显示在网页上  
           function setMessageInnerHTML(innerHTML) {  
              document.getElementById('message').innerHTML += innerHTML + '<br/>';  
          }  
         
          //关闭WebSocket连接  
           function closeWebSocket() {  
               websocket.close();  
           }  
        
           //发送消息  
           function send() {  
              var message = document.getElementById('text').value;  
              websocket.send(message);  
           }  
    </script>

  </body>

</html>